# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: xguo

import logging

from coin.exchange.base.order_gateway import OrderType
from coin.exchange.quoinex_v2.kr_rest.product import QuoinexProduct
from coin.exchange.quoinex_v2.order_gateway import QuoinexOrderGateway
from coin.strategy.executor.passive.simple_mm_executor import \
  SimpleMMExecutor
from coin.strategy.executor.util.traits import (order_logger, SpotExecutorTraits)
from coin.strategy.executor.aggressive.aggressive_executor import AggressiveExecutor


class QuoinexSimpleTraits(SpotExecutorTraits):
  def __init__(self, executor_config, order_gateway, logger=None):
    logger = logger or logging.getLogger('QuoinexSimpleTraits')
    super().__init__(executor_config, order_gateway, logger)

  @order_logger
  def _submit_order(self, product, price, qty, order_side):
    self.og.submit(product, price, qty, order_side, OrderType.LIMIT)

  def _cancel_orders_impl(self, order_id_list):
    self.og.cancel_multiple(order_id_list)


class QuoinexSimpleMMExecutor(SimpleMMExecutor):
  ProductType = QuoinexProduct
  OGType = QuoinexOrderGateway
  Traits = QuoinexSimpleTraits


class QuoinexSimpleAggExecutor(AggressiveExecutor):
  ProductType = QuoinexProduct
  OGType = QuoinexOrderGateway
  Traits = QuoinexSimpleTraits
